import greenfoot.*;
/**
 * Write a description of class Asteroid here.
 * 
 * Solo se ira moviendo el asteriode
 */
public class Asteroid  extends Actor
{
    // instance variables - replace the example below with your own
    

    private int size;
    private double exactX;
    private double exactY;
    public Asteroid()
    {
        this(50);
    }
    
    public Asteroid(int size)
    {
        setSize(size);
    }
    
    public void act()
    {         
        exactX = getX()+1;
        exactY = getY()+1;
        if(exactX >= getWorld().getWidth()) {
            exactX = 0;
        }
        if(exactX < 0) {
            exactX = getWorld().getWidth() - 1;
        }
        if(exactY >= getWorld().getHeight()) {
            exactY = 0;
        }
        if(exactY < 0) {
            exactY = getWorld().getHeight() - 1;
        }
        super.setLocation((int) exactX, (int) exactY);
        
        //Colision();
    }

    /**
     * Set the size of this asteroid. Note that stability is directly
     * related to size. Smaller asteroids are less stable.
     */
    public void setSize(int size) 
    {
        this.size = size;
        GreenfootImage image = getImage();
        image.scale(size, size);
    }
    
    /**
     * Checa si hay colision con el jugador
     */
    public void Colision()
    {
        Actor aux = getOneIntersectingObject(Jugador.class);
        if (aux != null)
        {
           getWorld().addObject( new Explosion(), getX(), getY() );
           getWorld().removeObject(aux);
        } 
    }
}
